package com.ruoyi.aitcommon.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.aitcommon.api.FlowOperation;
import com.ruoyi.aitcommon.utils.JSONResult;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;

@RestController
@RequestMapping("/aitcommon/zjk")
public class AitZJKController extends BaseController{
	
	@Autowired
    private FlowOperation flowOperation;
	
	/**
	 * 手工触发Flow
	 * @param type 是flowCode
	 * @param codes 原来传入数据编码集合,暂时不用
	 * @return
	 */
	@GetMapping("/handleflow")
    public JSONObject handleFlow(String type,String[] codes)
    {
		try {
//			调用Flow的api
			final JSONObject ret = flowOperation.templateAsync(type, 0, new String[0]);
//			因为是异步调用,等待1秒返回
//			Thread.sleep(1000);
			return ret;
		}catch(Exception ex) {
			return JSONResult.error(ex.getMessage());
		}
    }
	
}
